/**
 * 
 */
package parser;

/**
 * @author greg
 * Represents the location of a match in a text file
 */
public class StringMatch {
	public String fileName,value;
	public int lineNumber;
	public int startIndex;
	public int endIndex;
	
	public StringMatch() {}
	
	public StringMatch(String value, String fileName,int lineNumber, int startIndex,int endIndex) 
	{
		this.fileName = fileName;
		this.lineNumber = lineNumber;
		this.startIndex = startIndex;
		this.endIndex = endIndex;
		this.value = value;
	}
	
	public int hashCode() {
		return fileName.hashCode() ^ lineNumber ^ startIndex ^ endIndex;
	}
	
	public boolean equals(Object o) {
		if(o instanceof StringMatch) {
			StringMatch s = (StringMatch)o;
			if(this.fileName.equals(s.fileName) &&
					this.lineNumber == s.lineNumber &&
					this.startIndex == s.startIndex &&
					this.endIndex == s.endIndex)
				return true;
		}
		return false;
	}
	
	@Override
	public String toString() {
		return String.format("{%s:(%s,%s,%s,%s)}",value,fileName,lineNumber,startIndex,endIndex);
	}
}
